<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>本地存储</title>
</head>
<body>
  <h1>本地存储演示</h1>
  <button id="btn1">存</button>
  <button id="btn2">取</button>
  <script>
    btn1.onclick = () => {
      //setItem()用来存储数据
      //getItem()取数据
      //removeItem() 删除数据
      //clear() 清空
     sessionStorage.setItem("name","孙悟空")
    }
    btn2.onclick = () => {
      const name = sessionStorage.getItem("name")
      console.log(name);
    }
  </script>
</body>
</html>